package com.bdqn.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 2024-09-13
 * @Author:T369曹任柱
 */
@Configuration
@MapperScan("com.bdqn.mapper")
public class MyBatisPlusConfig {

    /**
     * 读写分离
     */
//    @Bean
//    public MasterSlaveAutoRoutingPlugin masterSlaveAutoRoutingPlugin() {
//        return new MasterSlaveAutoRoutingPlugin();
//    }

    /**
     * 新版本 分页插件，一级缓存和二级缓存遵循MyBatis的规则
     */
//    @Bean
//    public MybatisPlusInterceptor mybatisPlusInterceptor() {
//        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
//        return interceptor;
//    }
//
//    @Bean
//    public MybatisPlusInterceptor mybatisPlusInterceptor() {
//        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
//        //注册乐观锁插件
//        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
//        return mybatisPlusInterceptor;
//    }
}
